﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="author" content="Aowork">
    <meta name="description" content="">
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, maximum-scale=1.0">
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no">

    <title></title>

    <link href="../css/mobile.css" rel="stylesheet" />

    <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.1.0.js"></script>
    <script src="../js/zepto.min.js"></script>
    <script src="../js/zepto.swipe.js"></script>
    <script src="../js/common.js"></script>
    <script src="../js/config.js"></script>
    <script src="../js/uiExtend.js"></script>
    <script src="../js/wx_config.js"></script>

    <script type="text/javascript">
        jc.fnInit.push(function () {
            jc.ui.header.trigger("updateTitle", "首页");
            jc.ui.header.trigger("updateNavCurrent", 0);
        });
    </script>

</head>
<body>

    <div data-ui="header" class="J_header hasLogo">
        <div class="h_inner"></div>
    </div>


    <div data-ui="banner" class="J_banner"></div>

    <script type="text/javascript">
        jc.fnInit.push(function () {
            $.getJSON(window.path.banner, function (result) {
                if (result.success) {
                    jc.ui.banner.trigger("setup", result.data);
                }
            });

        });
    </script>

    <div data-source-parent="livingCourse" class="ptb10 bgfff bb1">

        <div class="J_title clearfix">
            <div class="t_left">
                <div class="l_token"></div>
                <div class="l_txt">正在直播</div>
            </div>
        </div>

        <div data-ui="courseHolder" data-source="livingCourse" data-router="player/living.html" data-keyword="token,title,price,label,realtimeOnlineCount" class="J_courseHolder">
            <div class="c_inner">

            </div>
        </div>

    </div>

    <script type="text/javascript">
        var livingUpdateTimer = null;
        jc.fnInit.push(function () {
            livingUpdate();
            clearInterval(livingUpdateTimer);
            livingUpdateTimer = setInterval(function () {
                livingUpdate();
            }, 4 * 1000);
        });
        function livingUpdate() {
            /* 初始化直播数据 */
            $.getJSON(window.path.livingCourse, { size: 100 }, function (livingCourseResult) {
                if (livingCourseResult.success) {
                    var livingCourseResultData = livingCourseResult.data;

                    jc.ui.header.trigger("getUser", function (user) {
                        if (!user) {
                            user = {};
                            user.uid = jc.cookie.get("u");
                        }

                        if (livingCourseResultData.length) {
                            /* 把所有courseId取出来 */
                            jc.ui.courseHolder.filter("source=livingCourse", "getDataArrayAttribute", livingCourseResultData, "courseId", function (courseIds) {
                                $.ajax({
                                    type: "GET",
                                    url: window.path.courseMoreInfo,
                                    data: {
                                        userId: user.uid,
                                        courseIds: courseIds
                                    },
                                    async: false,
                                    success: function (courseMoreInfoResult) {
                                        if (courseMoreInfoResult.success) {
                                            var courseMoreInfoResultData = courseMoreInfoResult.data
                                            jc.ui.courseHolder.filter("source=livingCourse", "mergeDataArrayAttribute", livingCourseResultData, courseMoreInfoResultData, "courseId", function (mergeDataArrayAttributeArray) {
                                                livingCourseResultData = mergeDataArrayAttributeArray;
                                            });
                                        }
                                    },
                                    dataType: "json"
                                });
                            });
                        }
                        /* 更新视图 */
                        jc.ui.courseHolder.filter("source=livingCourse", "setup", livingCourseResultData);

                    }, true);
                }
            });
        }
    </script>


    <div data-source-parent="newCourse" class="ptb10 bgfff bb1">

        <div class="J_title clearfix">
            <div class="t_left">
                <div class="l_token"></div>
                <div class="l_txt">最新课程</div>
            </div>
        </div>

        <div data-ui="courseHolder" data-source="newCourse" data-router="courseDetails/courseDetails.html" data-keyword="title,price,label,courseProgress" class="J_courseHolder">
            <div class="c_inner">

            </div>
        </div>

    </div>

    <script type="text/javascript">
        jc.fnInit.push(function () {
            $.getJSON(window.path.newCourse, { size: 4 }, function (result) {
                if (result.success) {
                    jc.ui.courseHolder.filter("source=newCourse", "setup", result.data);
                }
            });
        });
    </script>


    <div data-source-parent="hotCourse" class="ptb10 bgfff bb1">

        <div class="J_title clearfix">
            <div class="t_left">
                <div class="l_token"></div>
                <div class="l_txt">推荐课程</div>
            </div>
        </div>

        <div data-ui="courseHolder" data-source="hotCourse" data-router="courseDetails/courseDetails.html" data-keyword="title,price,label,courseProgress" class="J_courseHolder">
            <div class="c_inner">

            </div>
        </div>

    </div>

    <script type="text/javascript">
        jc.fnInit.push(function () {
            $.getJSON(window.path.hotCourse, { size: 4 }, function (result) {
                if (result.success) {
                    jc.ui.courseHolder.filter("source=hotCourse", "setup", result.data);

                }
            });
        });
    </script>


    <div data-ui="footer" class="J_footer">


    </div>


    <div data-ui="nav" class="J_nav">
        <div class="n_inner">
            <div class="i_center clearfix"></div>
        </div>
    </div>




</body>
</html>
